﻿using CommunityToolkit.Mvvm.Input;
using System;
using System.Windows.Input;
namespace SampleAvaloniaMvvm.ViewModels
{
    public partial class MainWindowViewModel : ViewModelBase
    {
        private MainWindowViewModel()
        {

        }

        IServiceProvider m_provider;
        public MainWindowViewModel(IServiceProvider provider)
        {
            m_provider = provider;
            initial_command();
        }
        //private MainWindowViewModel()
        //{
        //}
        #region property 
        string m_title = "Title Text";
        string m_greeting = "中文 Welcome to Avalonia";
        private string m_btn_width = "300";
        int m_count = 0; 
        string m_counter = $"计数:0";


        public string g_counter { get => m_counter; set => SetProperty(ref m_counter, value); }
        public string g_title { get => m_title; set => SetProperty(ref m_title, value); }
        public string g_greeting { get => m_greeting; set => SetProperty(ref m_greeting, value); }
        public string g_btn_width { get => m_btn_width; set => SetProperty(ref m_btn_width, value); }
        #endregion                             
        #region command 

        void initial_command()
        {
            say_hello_command = new RelayCommand(say_hello);
            do_count_command = new RelayCommand(do_count);

        }
        public ICommand say_hello_command { get; private set; }
        public ICommand do_count_command { get; private set; }
        private void do_count()
        {
            m_count++;
            g_counter = $"计数:{m_count}";
        }
        private void say_hello()
        {
            g_greeting = "Hello ";
            g_title = $"{Guid.NewGuid().ToString().ToUpper()} Title ";
            g_btn_width = "400";
        }
        #endregion 

        string[] m_combo_items = new string[] { "KLSJDF" ,  "LKSJDF", "LSKDJF" };  
        public string[] g_combo_items { get => m_combo_items; set => SetProperty(ref m_combo_items, value); }
    }
}
